package com.gray.wow.domain;

import java.util.List;

public class PageModel {
	
	private Integer currentPage;
	private Integer pageSize;
	private Integer totalPage;
	private Integer totalRecord;
	private List<?> list;

	public Integer getCurrentPage() {
		return currentPage;
	}

	public void setCurrentPage(Integer currentPage) {
		this.currentPage = currentPage;
	}

	public Integer getPageSize() {
		return pageSize;
	}

	public void setPageSize(Integer pageSize) {
		this.pageSize = pageSize;
	}

	public Integer getTotalPage() {
		if(list==null || list.size()==0){
			return 0;
		}
		return totalPage;
	}

	public void setTotalPage(Integer totalPage) {
		this.totalPage = totalPage;
	}

	public Integer getTotalRecord() {
		if(list==null || list.size()==0){
			return 0;
		}
		return totalRecord;
	}

	public void setTotalRecord(Integer totalRecord) {
		this.totalRecord = totalRecord;
	}


	public List<?> getList() {
		return list;
	}

	public void setList(List<?> list) {
		this.list = list;
	}

	public static  PageModel getPageModel(Integer pageSize, Integer page,
			int count, List<?> list) {
		PageModel pm = new PageModel();
		pm.setList(list);
		pm.setTotalRecord(count);
		pm.setPageSize(pageSize);
		pm.setCurrentPage(page);
		if(pageSize!=null){
			pm.setTotalPage((count + pageSize - 1) / pageSize);
		}
		return pm;
	}
}
